
function preViewPrint(title,type,it,y){
    LODOP=getLodop();
    LODOP.SET_PRINTER_INDEX("EPSON LQ-520K ESC/P2");//指定打印机
    LODOP.SET_PRINT_PAGESIZE(0,0,0,"24.1*279.4-结算单");
    // LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "24.1*279.4-结算单");
    LODOP.SET_PRINT_MODE("WINDOW_DEFPRINTER","EPSON LQ-520K ESC/P2");
    // LODOP.SET_PRINT_MODE("WINDOW_DEFPAGESIZE:EPSON LQ-520K ESC/P2","24.1*279.4-结算单");

    var strStyle = "<style>table{border-collapse: collapse;table-layout:fixed; }td {height: 6.82mm;}</style>";
    var header_1 = document.getElementById("header_1").innerHTML;
    var body_2   = strStyle+document.getElementById("body_2").innerHTML;
    var tfoot_3  = document.getElementById("tfoot_3").innerHTML;
    if (type==1){
        LODOP.ADD_PRINT_TABLE("234.75pt","5.25pt","99.005%","253.5pt",body_2);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        LODOP.ADD_PRINT_HTM("-2.25pt","5.25pt","99.005%","233.25pt",header_1);
        LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
        LODOP.ADD_PRINT_HTM("511.5pt","7.5pt","99.546%","256.5pt",tfoot_3);
        LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
    } else if (type==2) {
        if (it==0){
            LODOP.ADD_PRINT_TABLE("234.75pt","5.25pt","99.005%","293.25pt",body_2);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.ADD_PRINT_HTM("-2.25pt","5.25pt","99%","233.25pt",header_1);
            LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.ADD_PRINT_HTM("533.25pt","5.25pt","99.005%","222pt",tfoot_3);
            LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        } else if (it==1) {
            //寄存
            LODOP.ADD_PRINT_TABLE("234.75pt","5.25pt","99.005%","155.78pt",body_2);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.ADD_PRINT_HTM("-2.25pt","5.25pt","99.005%","233.25pt",header_1);
            LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.ADD_PRINT_HTM("393.75pt","5.25pt","99.005%","375.75pt",tfoot_3);
            LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        }
    } else if (type==3) {
        LODOP.ADD_PRINT_TABLE("234.75pt","5.25pt","99.005%","350.25pt", body_2);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        LODOP.ADD_PRINT_HTM("-2.25pt", "5.25pt", "99%", "233.25pt", header_1);
        LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        LODOP.ADD_PRINT_HTM("596.25pt","7.5pt","99.005%","163.5pt", tfoot_3);
        LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
    }else if (type==4){
        LODOP.ADD_PRINT_TABLE("234.75pt","5.25pt","88.951%","374.25pt",body_2);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        LODOP.ADD_PRINT_HTM("-2.25pt","5.25pt","99%","233.25pt",header_1);
        LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
        LODOP.ADD_PRINT_HTM("620.75pt","5.25pt","95.892%","211.5pt",tfoot_3);
        LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
        LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
    }
    // if (y==1){
    //     LODOP.SET_PREVIEW_WINDOW(0,0,0,900,900,"");// 无工具条和按钮的小窗口纯
    // }else {
    //     LODOP.SET_PREVIEW_WINDOW(0,1,0,900,1000,"");//打印前弹出选择打印机的对话框
    // }
    LODOP.SET_PRINT_MODE("AUTO_CLOSE_PREWINDOW",1);//打印后自动关闭预览窗口
    if (LODOP.CVERSION) {
        CLODOP.On_Return=function(TaskID,Value){
            console.log(Value)
            if (Value)
                console.log("已发出实际打印命令！");
            else
                console.log("放弃打印！"); };
        LODOP.PREVIEW();
        return;
    };

    // LODOP.PREVIEW();
    // LODOP.PRINT_SETUP();//打印维护
    // LODOP.PRINT_DESIGN();//打印设计
}


function service_preview(title,type,year,no) {
    LODOP=getLodop();
    LODOP.PRINT_INITA("0mm","0mm","244.74mm","275.17mm",title);
    // LODOP.SET_PRINTER_INDEXA("EPSON LQ-520K ESC/P2");//指定打印机
    // LODOP.SET_PRINT_PAGESIZE(1,0,0,"24.13*13.97-打印单据");

    LODOP.SET_PRINT_MODE("WINDOW_DEFPRINTER","EPSON LQ-520K ESC/P2");
    LODOP.SET_PRINT_MODE("WINDOW_DEFPAGESIZE:EPSON LQ-520K ESC/P2","24.13*13.97-打印单据");

    switch (type) {
        case 1:
            LODOP.ADD_PRINT_TEXT(16,235,330,44,title);
            LODOP.SET_PRINT_STYLEA(0,"FontName","隶书");
            LODOP.SET_PRINT_STYLEA(0,"FontSize",20);
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.ADD_PRINT_TEXT(68,50,167,28,year);
            LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
            LODOP.ADD_PRINT_TEXT(68,600,41,25,"NO:");
            LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
            LODOP.SET_PRINT_STYLEA(0,"FontColor","#FF0000");
            LODOP.ADD_PRINT_TEXT(68,646,115,25,no);
            LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
            var strStyle="<style>table tr{height: 34pt;text-align: center;font-size: 16px;}</style>";
            LODOP.ADD_PRINT_TABLE("79.5pt","3pt","98.995%","374.25pt",strStyle+document.getElementById("body_2").innerHTML);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.ADD_PRINT_HTM("331.73pt","6.75pt","99.005%","19.5pt", document.getElementById("tfoot_3").innerHTML);
            break;
        case 4:
            LODOP.ADD_PRINT_TEXT(16,235,330,44,title);
            LODOP.SET_PRINT_STYLEA(0,"FontName","隶书");
            LODOP.SET_PRINT_STYLEA(0,"FontSize",20);
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.ADD_PRINT_TEXT("33pt","37.5pt","125.25pt","18.75pt",year);
            LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
            LODOP.ADD_PRINT_TEXT("33pt","450pt","30.75pt","18.75pt","NO:");
            LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
            LODOP.SET_PRINT_STYLEA(0,"FontColor","#FF0000");
            LODOP.ADD_PRINT_TEXT("33pt","484.5pt","86.25pt","18.75pt",no);
            LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
            var strStyle="<style>table tr{height: 15pt;text-align: center;font-size: 11px;}</style>";
            LODOP.ADD_PRINT_TABLE("49.5pt","3pt","99.005%","276.95pt",strStyle+document.getElementById("body_2").innerHTML);
            LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
            LODOP.ADD_PRINT_HTM("340.73pt","3pt","99.005%","19.5pt", document.getElementById("tfoot_3").innerHTML);
            break;
    }

    // LODOP.SET_PREVIEW_WINDOW(0,0,0,900,900,"");// 无工具条和按钮的小窗口纯
    // LODOP.SET_PREVIEW_WINDOW(0,1,0,1100,700,"");//打印前弹出选择打印机的对话框
    LODOP.SET_PRINT_MODE("AUTO_CLOSE_PREWINDOW",1);//打印后自动关闭预览窗口
    if (LODOP.CVERSION) {
        CLODOP.On_Return=function(TaskID,Value){
            console.log(Value)
            if (Value)
                console.log("已发出实际打印命令！");
            else
                console.log("放弃打印！"); };
        LODOP.PREVIEW();
        return;
    };

    // LODOP.PREVIEW();
    // LODOP.PRINT_SETUP();//打印维护
    // LODOP.PRINT_DESIGN();//打印设计
};